package com.magic.ch02_二分与前缀和.子矩阵的和;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        String[] read = br.readLine().split(" ");
        int n = Integer.parseInt(read[0]);
        int m = Integer.parseInt(read[1]);
        int q = Integer.parseInt(read[2]);

        int[][] map = new int[n + 5][m + 5];
        for (int i = 1; i <= n; i++) {
            read = br.readLine().split(" ");
            for (int j = 1; j <= m; j++) {
                map[i][j] = Integer.parseInt(read[j - 1]) + map[i - 1][j] + map[i][j - 1] - map[i - 1][j - 1];
            }
        }

        while (q > 0) {
            read = br.readLine().split(" ");
            int x1 = Integer.parseInt(read[0]);
            int y1 = Integer.parseInt(read[1]);
            int x2 = Integer.parseInt(read[2]);
            int y2 = Integer.parseInt(read[3]);

            int ans = map[x2][y2] - map[x2][y1 - 1] - map[x1 - 1][y2]+map[x1-1][y1-1];
            pw.println(ans);
            q--;
        }
        br.close();
        pw.flush();
        pw.close();
    }
}
